--By Wsdx233 万能列表模块
require "import"
import "android.content.Context"
import "java.lang.String"
import "android.widget.*"
import "android.view.*"

activity.getActionBar().subtitle = "点击可复制"

cf = io.open(activity.getLuaPath("res/commands.txt"),"r")
commans = cf:read("*a")
mdata = String(commans).split("\n")
data = {}
for i =0,#mdata-1,1 do
  table.insert(data,{title=mdata[i]})

end


list = ListView()

activity.setContentView(list)

_layout = {
  RelativeLayout;
  id="root";
  layout_width="fill";
  layout_height="wrap";
  {
    TextView;
    text="Title";
    textColor="#263238";
    textSize="15sp";
    id="title";
    layout_margin="15dp";
    layout_centerVertical="true";
  };
};


adapter = LuaAdapter(activity,data,_layout)
list.adapter = adapter

--即时通知数据修改
adapter.setNotifyOnChange(true)

list.onItemClick = function(list,v,c,i)
  activity.getSystemService(Context.CLIPBOARD_SERVICE).setText(data[i].title)
  print("已复制!")
end